<template>
  <div class="home">
    <van-search
      v-model="value"
      show-action
      label="上海▼"
      placeholder="请输入搜索关键词"
    >
      <template #action>
        <div><van-icon name="guide-o" /></div>
      </template>
    </van-search>
    <div class="swipper">
      <van-swipe :autoplay="3000">
        <van-swipe-item v-for="(image, index) in images" :key="index">
          <img v-lazy="image" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <van-grid square>
      <van-grid-item icon="wap-home-o" text="整租" />
      <van-grid-item icon="friends-o" text="合租" />
      <van-grid-item icon="location-o" text="地图找房" />
      <van-grid-item icon="diamond-o" text="去出租" />
    </van-grid>
    <div class="zfxz">
      <div class="header">
        <h4>租房小组</h4>
        <span>更多</span>
      </div>
      <div class="content">
        <van-grid direction="horizontal" :column-num="2" gutter="8px">
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  name: 'home-page',
  async created() {
    const { body } = await request({
      method: 'GET',
      url: '/home/swiper'
    })
    // console.log(body)
    this.images = body.map((item) => 'http://liufusong.top:8080' + item.imgSrc)
  },
  data() {
    return {
      images: [],
      value: ''
    }
  },
  methods: {}
}
</script>

<style scoped lang="less">
.home {
  background-color: #f7f7f7;
}
// .van-search {
//   // position: fixed;
//   // left: 20px;
//   // top: 10px;
//   // background-color: #333;
// }
.swipper {
  width: 100%;
  height: 220px;
  .van-swipe img {
    width: 100%;
  }
}

.zfxz {
  margin: 10px 10px 0;
  .header {
    display: flex;
    justify-content: space-between;
    // font-size: 15px;
  }
  .content {
    width: 100%;
    height: 160px;
    margin-top: 5px;
    // background-color: aqua;
    // display: flex;
  }
}
</style>
